/*
 * WorldElement.cpp
 *
 *  Created on: 02.10.2012
 *      Author: caffeine
 */

#include "WorldElement.h"

namespace irr{
namespace object{

WorldElement::WorldElement(irr::scene::ISceneManager*manager,ContainerNodeObject*parent,bool sync_load):ContainerNodeObject(manager,parent),PositionObject(),PosittedContainerNodeObject(manager,parent),ModelLoaderObject(0,sync_load){
	radius=2;
}

void WorldElement::on_load(){
	if (getModel())
		getModel()->load();
}
void WorldElement::on_unload(){
	if (getModel())
		getModel()->unload();
}

WorldElement::~WorldElement() {
	//nothing
}

void WorldElement::setModel(ModelObject*model){
	ModelLoaderObject::setModel(model);
	if (model)
		model->setContainer(this);
}

irr::core::stringc WorldElement::getSerializationNodeName(){
	return "object:worldelement";
}

void WorldElement::getSerialized(irr::xml::IXmlNode*node){
	PosittedContainerNodeObject::getSerialized(node);
	PhysicObject::getSerialized(node);
}

irr::xml::TagResult WorldElement::setSerialized(irr::xml::IXmlNode*node){
	PosittedContainerNodeObject::setSerialized(node);
	PhysicObject::setSerialized(node);
	return irr::xml::NEXT;
}

irr::f32 WorldElement::getRadiusObjectSize(){
	return radius;
}

void WorldElement::setRadiusObjectSize(irr::f32 r){
	radius=r;
}

bool WorldElement::isLoaded(){
	if (!getModel())
		return false;
	return getModel()->isLoaded();
}

bool WorldElement::isUnloaded(){
	if (!getModel())
		return false;
	return getModel()->isUnloaded();
}

}//namespace object
}//namespace irr
